import logo from './logo.svg';
import './App.css';
import React, { useCallback, useEffect, useState } from 'react';
import { click } from '@testing-library/user-event/dist/click';
import { useMemo,useRef} from 'react';
import { createPortal } from 'react-dom';
//  子组件传递给父组件
function Son(props){
const {changeMsg}=props
const sonMsg='我是子组件传递过来的'
return(
  <div>
    <button onClick={()=>{changeMsg(sonMsg)}}>sendMSG</button>
  </div>
)
}

function Father(){
  const [msg,setMsg]=useState('')
  const changeMsg=(m)=>{
    setMsg(m)
  }
  return (
    <div>
      <div>{msg}</div>
      <Son changeMsg={changeMsg} />
    </div>
  )
  }
  


export default Father;
